package com.sikao.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sikao.app.R;
import com.sikao.app.bean.MyEvaluationListBean;
import com.sikao.app.utils.TimeUtil;

import java.util.List;

/**
 * Created by y50 on 2016/5/6.
 */
public class MyEvaluateAdapter extends BaseAdapter {

	private Context context;
	private List<MyEvaluationListBean.ResBean.ListBean> beans;

	public MyEvaluateAdapter(Context context, List<MyEvaluationListBean.ResBean.ListBean> beans) {
		this.context = context;
		this.beans = beans;
	}

	@Override
	public int getCount() {
		return beans.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view;
		ViewHolder viewHolder;
		if (convertView == null) {
			view = View.inflate(context, R.layout.evaluate_list_item, null);
			viewHolder = new ViewHolder(view);
			view.setTag(viewHolder);
		} else {
			view = convertView;
			viewHolder = (ViewHolder) view.getTag();
		}
		viewHolder.tvname.setText(beans.get(position).getTitle());
		viewHolder.tvcontent.setText(beans.get(position).getContent());
		viewHolder.tvtime.setText(TimeUtil.timeStampToTime(beans.get(position).getAdd_time(), TimeUtil.fotmatString2));
		viewHolder.tvevaluate.setText("服务态度:" + beans.get(position).getScore_1() + "分 | 货物品质:" +
				beans.get(position).getScore_2() + "分 | 发货效率:" + beans.get(position).getScore_3() + "分");
		return view;
	}

	public class ViewHolder {
		public final TextView tvname;
		public final TextView tvevaluate;
		public final TextView tvcontent;
		public final TextView tvtime;
		public final View root;

		public ViewHolder(View root) {
			tvname = (TextView) root.findViewById(R.id.tv_name);
			tvevaluate = (TextView) root.findViewById(R.id.tv_evaluate);
			tvcontent = (TextView) root.findViewById(R.id.tv_content);
			tvtime = (TextView) root.findViewById(R.id.tv_time);
			this.root = root;
		}
	}
}
